<template>
    <div>
        <div class="container">
            <!-- 头部 -->
            <div class="nav">
                <div class="nav_wrap">
                    <div class="quit" @click="$router.back()"></div>
                    <span>登录</span>
                    <div class="nav_icon">
                        <router-link tag="a" to="/"></router-link>
                        
                        <i v-show="!isTop"></i>
                        <i class="topnav" v-show="isTop" @click="topShow"></i>
                    </div>
                </div>
            </div>
            <div class="wrap" v-show="isTop" @click.self="topShow">
                <div class="subnav">
                    <ul>
                        <router-link tag="li" to="/">
                            <img src="../assets/images/tp_1.png" alt="">
                            <span>首页</span>
                        </router-link>
                        <router-link tag="li" to="/library">
                            <img src="../assets/images/tp_02.png" alt="">
                            <span>书库</span>
                        </router-link>
                        <router-link tag="li" to="/shelf">
                            <img src="../assets/images/tp_03.png" alt="">
                            <span>书架</span>
                        </router-link>
                        <router-link tag="li" to="/user">
                            <img src="../assets/images/tp_04.png" alt="">
                            <span>账户</span>
                        </router-link>
                        <router-link tag="li" to="/pay">
                            <img src="../assets/images/tp_05.png" alt="">
                            <span>充值</span>
                        </router-link>
                        <router-link tag="li" to="/search">
                            <img src="../assets/images/tp_06.png" alt="">
                            <span>搜索</span>
                        </router-link>
                    </ul>
                </div>
            
            </div>
            <!-- 用户头像信息 -->
            <div class="header">
                <div class="author">
                    <img src="../assets/images/author.png" alt="">
                </div>
            </div>
            <!-- 用户账号信息 -->
            <div class="form">
                <div class="name">
                    <input type="text" placeholder="请输入手机号" v-model="username">
                </div>
                <div class="key">
                    <input type="password" placeholder="请输入密码" v-model="userkey">
                </div>
                <div class="vcode" v-show="prove">
                    <input type="text" placeholder="请输入验证码" v-model="vcode">
                    <a href="javascript:;" @click="getCode">获取短信验证码</a>
                </div>
                <div class="btn" @click="go">
                    立即登录
                </div>
            </div>
            <div class="user_info bor_bot">
                忘记密码
            </div>
            <!-- 搜索框 -->
            <router-link tag="div" to="/search" class="search">
                <div class="search_wrap">
                    <input type="text">
                    <button></button>
                </div>
            </router-link>
            <!-- 页脚信息 -->
            <div class="footer">
                <div class="foot_tit">
                    <ul>
                        <li>
                            <a href="javascript:;">首页</a>
                        </li>
                        <li>
                            <a href="javascript:;">书库</a>
                        </li>
                        <li>
                            <a href="javascript:;">书架</a>
                        </li>
                        <li>
                            <a href="javascript:;">账户</a>
                        </li>
                        <li>
                            <a href="javascript:;">客户端</a>
                        </li>
                    </ul>
                </div>
                <div class="foot_cont">
                    <div class="foot_info">
                        <p>客服QQ群：326738643</p>
                        <p>客服电话：010-86462015-800</p>
                        <p>©2020北京爱书客科技有限公司</p>
                        <p>京ICP备13037522号</p>
                    </div>
                    <div class="info_img">
                        <img src="../assets/images/ledu.png" alt="">
                        <span>乐读书城</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                isTop: false,//判断子菜单的展示
                username:"",
                userkey:"",
                vcode:"",
                prove:false
            }
        },
        created(){
            console.log('created');
            let phone = ['17875337096','17875337094'];
            window.localStorage.setItem("user",JSON.stringify(phone));
        }, 
        methods:{
            topShow() {
                this.isTop = !this.isTop
            },
            go(){
                let phone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
                if (this.username == "" || phone.test(this.phone)){
                    this.$toast("请输入手机号")
                    return
                } 
                console.log(1);
                let user = window.localStorage.getItem("user");
                user = JSON.parse(user);
                if (!user.includes(this.username)){
                    user.push(this.username)
                    window.localStorage.setItem("user",JSON.stringify(user))
                    this.prove = true;
                    return
                } 
                console.log(2);
                 if(this.userkey == ""){
                    this.$toast("请输入密码")
                    return
                }
                console.log(3);
                window.localStorage.setItem("token", "token值");
                console.log('push');
                this.$router.push('/')
            },
            getCode(){
                this.$toast("验证码：6666");
            }
        }
    }
</script>

<style lang="scss" scoped>
.nav {
    background-color: #fff;

    .nav_wrap {
        padding: 0 14px;
        border-bottom: 1px solid #e0e0e0;
        display: flex;

        .quit {
            width: 10px;
            height: 45px;
            background-image: url('../assets/images/quit.png');
            background-repeat: no-repeat;
            background-size: 100%;
            background-position: center;
        }

        span {
            color: #333;
            font-size: 16px;
            display: block;
            text-align: center;
            line-height: 45px;
            width: 54%;
            padding-left: 70px;
        }

        .nav_icon {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 80px;

            a {
                display: block;
                width: 25px;
                height: 22px;
                background-image: url('../assets/images/book_ico1.png');
                background-repeat: no-repeat;
                background-size: 100%;
                background-position: center;
            }

            i {
                display: block;
                width: 20px;
                height: 20px;
                background-image: url('../assets/images/bookMore_ico1.png');
                background-size: 100%;
                background-position: center;

            }

            .topnav {
                background-image: url('../assets/images/tp_close.png');
            }
        }
    }
}

.wrap {
    position: fixed;
    top: 45px;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, .8);

    .subnav {
        width: 100%;
        background-color: #fff;
        padding-bottom: 18px;

        ul {
            display: flex;
            flex-wrap: wrap;

            li {
                width: 25%;
                text-align: center;
                padding-top: 20px;

                img {
                    width: 40px;
                    height: 40px;
                    margin: 0 auto 8px auto;
                }

                span {
                    font-size: 13px;
                    color: #666;
                }
            }
        }
    }

}
.form{
    padding: 0 30px;
    div{
        background-repeat: no-repeat;
        background-position: center left;
        text-align: right;
        padding: 8px 0;
    }
    .name{
        input{
            background-image: url('../assets/images/userIco.png');
            
            background-size: 20px;
        }
    }
    .key{
        input{
            background-image: url('../assets/images/passIco.png');
            background-size: 13px;
        }
    }
    .vcode{
        input{
            width: 60%;
            padding-left: 0px;
        }
        a{
            display: inline-block;
            padding: 3px 5px;
            background-color: #ea4136;
            color: #fff;
            border-radius: 5px;
            font-size: 12px;
        }
    }
    input{
        width: 90%;
        height: 30px;
        border: 1px solid #eee;
        padding-left: 30px;
        background-repeat: no-repeat;
        background-position: center left;
    }
    .btn{
        width: 100%;
        height: 42px;
        border-radius: 21px;
        background-color: #ea4136;
        color: #fff;
        line-height: 42px;
        text-align: center;
        font-size: 16px;
        padding: 0;
        margin-top: 20px;
    }
}
.user_info{
    text-align: right;
    padding: 0 30px 60px 30px;
    font-size: 13px;
    color: #b6b6b6;
    margin-top: 8px;
}
.header {
    padding: 35px 0;

    .author {
        width: 59px;
        height: 59px;
        margin: 0 auto;
    }
}
.bor_bot {
    border-bottom: 10px solid #eaeaea;
}

.search {
    padding: 10px 14px;

    .search_wrap {
        display: flex;
        padding: 4px 0 4px 17px;
        border: 1px solid #dbdbdb;
        height: 32px;
        border-radius: 20px;
        overflow: hidden;

        &>input {
            border: 0px;
            outline: none;
            flex: 6;
            color: #999;
        }

        &>button {
            flex: 1;
            background-image: url('../assets/images/searchBar.png');
            background-repeat: no-repeat;
            border: 0px;
            background-color: #fff;
            position: relative;
            border-left: 1px solid #dbdbdb;
            background-size: 18px;
            background-position: center;
        }
    }
}

.footer {
    padding: 16px 0px 32px 0px;
    background-color: #1c1a1a;

    .foot_tit {
        padding-bottom: 15px;

        ul {
            display: flex;

            li {
                flex: 1;

                a {
                    display: block;
                    font-size: 16px;
                    color: #b6b6b6;
                    text-align: center;
                    border-right: 1px solid #999999;

                }

                &:last-of-type {
                    a {
                        border: 0px;
                    }
                }
            }
        }
    }

    .foot_cont {
        display: flex;
        justify-content: space-between;
        padding: 0 16px;

        .foot_info {
            p {
                color: #b6b6b6;
                font-size: 12px;
                line-height: 28px;
            }
        }

        .info_img {
            img {
                width: 98px;
                height: 98px;
            }

            span {
                font-size: 12px;
                display: block;
                text-align: center;
                color: #b6b6b6;
                padding-top: 3px;
            }
        }
    }
}
</style>